package com.ny.service.Impl;

import com.ny.dao.StudentDao;
import com.ny.dao.lmpl.StudentDaolmpl;
import com.ny.entity.Student;
import com.ny.service.StudentService;


import java.sql.SQLException;

public class StudentServiceImpl implements StudentService {
    //        创建数据访问层的对象
    private StudentDao  studentDao = new StudentDaolmpl();
    public StudentServiceImpl() throws SQLException, ClassNotFoundException {
    }
    @Override
    public int add(Student student) throws SQLException, ClassNotFoundException {
//        调用数据访问层的添加方法
        return studentDao.add(student);

    }

    @Override
    public Student login(String studentName, String studentPassword) throws SQLException, ClassNotFoundException {
        return studentDao.login(studentName, studentPassword);
    }

    @Override
    public Student deleteStu(String username, String pwd) throws SQLException, ClassNotFoundException {
        StudentDao studentDao = new StudentDaolmpl();
        return studentDao.deleteStu(username, pwd);
    }

    @Override
    public void addStudent(Student stud1) {
        try {
            studentDao.add(stud1);
        } catch (SQLException e) {
            System.out.println("添加学生失败：" + e.getMessage());
        }
    }

}
